<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <title>底部</title>
    <link rel="stylesheet" type="text/css" href="../css/aui.css" />
</head>
<body>
    <header class="aui-bar aui-bar-nav aui-bar-warning" id="aui-header">
        <a class="aui-btn aui-btn-warning aui-pull-left" tapmode onclick="closeWin()">
            <span class="aui-iconfont aui-icon-left"></span>
        </a>
        <div class="aui-title" id="header-title">栏目1</div>
    </header>
    <footer class="aui-nav" id="aui-footer">
        <ul class="aui-bar-tab">
            <li class="active-warning" id="tabbar1" tapmode onclick="randomSwitchBtn(this,'栏目1',0)">
                <span class="aui-iconfont aui-icon-favor"></span>
                <p>栏目1</p>
            </li>
            <li id="tabbar2" tapmode onclick="randomSwitchBtn(this,'栏目2',1)">
                <span class="aui-iconfont aui-icon-mark"></span>
                <p>栏目2</p>
            </li>
            <li id="tabbar3" tapmode onclick="randomSwitchBtn(this,'栏目3',2)">
                <span class="aui-iconfont aui-icon-like"></span>
                <p>栏目3</p>
            </li>
            <li id="tabbar4" tapmode onclick="randomSwitchBtn(this,'栏目4',3)">
                <span class="aui-iconfont aui-icon-my"></span>
                <p>栏目4</p>
            </li>
        </ul>
    </footer>
</body>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript">
    apiready = function(){
        api.parseTapmode();
        var header = $api.byId('aui-header');
        $api.fixStatusBar(header); 
        var headerPos = $api.offset(header);
        var body_h = $api.offset($api.dom('body')).h;
        var footer_h = $api.offset($api.byId('aui-footer')).h;
        api.openFrameGroup ({
            name: 'footer_tab_demo',
            scrollEnabled:true,
            rect:{x:0, y:headerPos.h, w:'auto', h:body_h - headerPos.h - footer_h},
            index:0,
            preload:3,
            frames:
            [{
                name: 'footer_tab_1', 
                url: 'footer_tab_1.html', 
                bounces:false
            },{
                name: 'footer_tab_2', 
                url: 'footer_tab_2.html', 
                bounces:false
            },{
                name: 'footer_tab_3', 
                url: 'footer_tab_3.html', 
                bounces:false
            },{
                name: 'footer_tab_4', 
                url: 'footer_tab_4.html', 
                bounces:false
            }]
        }, function(ret, err){
            var footer = $api.byId('aui-footer');
            var footerAct = $api.dom(footer, '.aui-bar-tab li.active-warning');
            $api.removeCls(footerAct, 'active-warning');
            var name = ret.name;
            var index = ret.index;
            if(index==0){
                $api.text($api.byId('header-title'),'栏目1');
                $api.addCls($api.byId('tabbar1'), 'active-warning');
            }else if(index==1){
                $api.text($api.byId('header-title'),'栏目2');
                $api.addCls($api.byId('tabbar2'), 'active-warning');
            }else if(index==2){
                $api.text($api.byId('header-title'),'栏目3');
                $api.addCls($api.byId('tabbar3'), 'active-warning');
            }else if(index==3){
                $api.text($api.byId('header-title'),'栏目4');
                $api.addCls($api.byId('tabbar4'), 'active-warning');
            }
        })
    }
    function closeWin(){
        api.closeWin();
    }
    function randomSwitchBtn(obj, name, index) {
        $api.text($api.byId('header-title'),name);
        var footer = $api.byId('aui-footer');
        var footerAct = $api.dom(footer, '.aui-bar-tab li.active-warning');
        $api.removeCls(footerAct, 'active-warning');
        $api.addCls(obj, 'active-warning');
        api.setFrameGroupIndex({
            name: 'footer_tab_demo',
            index: index,
            scroll:true
        });

    }
</script>
</html>